package com.kgc.storeprovider.service.impl;

import com.kgc.basic.util.ResponseMsg;
import com.kgc.store.pojo.InventoryCheckDetail;
import com.kgc.store.pojo.InventoryLossDetail;
import com.kgc.storeprovider.dao.InventoryCheckDetailMapper;
import com.kgc.storeprovider.dao.InventoryLossDetailMapper;
import com.kgc.storeprovider.service.InventoryLossDetailService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InventoryLossDetailServiceImpl implements InventoryLossDetailService {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private InventoryLossDetailMapper inventoryLossDetailMapper;

    @Override
    public ResponseMsg getInventoryLossDetailList(String inventoryLossCode) {
        logger.info("InventoryLossDetailServiceImpl getInventoryLossDetailList inventoryLossCode:"+inventoryLossCode);
        ResponseMsg msg = new ResponseMsg();
        List<InventoryLossDetail> inventoryLossDetailList = inventoryLossDetailMapper.getInventoryLossDetailList(inventoryLossCode);
        logger.debug("InventoryLossDetailServiceImpl getInventoryLossDetailList inventoryLossDetailList:"+inventoryLossDetailList);
        msg.setCode("200");
        msg.setData(inventoryLossDetailList);
        logger.debug("InventoryLossDetailServiceImpl getInventoryLossDetailList msg:"+msg);
        return msg;
    }

    @Override
    public ResponseMsg delInventoryLossDetail(String inventoryLossCde) {
        ResponseMsg msg = new ResponseMsg();
        int delCount = inventoryLossDetailMapper.delInventoryLossDetail(inventoryLossCde);
        if(delCount>0){
            msg.setData(true);
            msg.setCode("200");
        }else{
            msg.setData(false);
            msg.setCode("201");
        }
        return msg;
    }

    @Override
    public ResponseMsg insertInventoryLossDetail(InventoryLossDetail inventoryLossDetail) {
        ResponseMsg msg = new ResponseMsg();
        int insertCount = inventoryLossDetailMapper.insertInventoryLossDetail(inventoryLossDetail);
        if(insertCount>0){
            msg.setData(true);
            msg.setCode("200");
        }else{
            msg.setData(false);
            msg.setCode("201");
        }
        return msg;
    }
}
